#ifndef PRIM_NODES_H
#define PRIM_NODES_H
#include "global_def.h"
#include "nodes/nodes.h"
#include "nodes/op_list.h"
#include "nodes/parse_nodes.h"

/**
 * parse_state_t
 */
typedef struct parse_state_t {
    int                 p_last_res_no;
    list_t              *p_target_res_nos;
    list_t              *p_rtable;
    int                 p_query_is_rule;
} parse_state_t;

typedef struct aggreg_t {
    node_tag_t	type;
    char        *aggname;
    oid_t       basetype;   /* base type of the aggregate */
    oid_t		aggtype;	/* type of final result */
    node_t		*target;	/* attribute to aggreg on */
    int			aggno;		/* index to ecxt_values */
} aggreg_t;

/* ----------------
 * Expr
 *	typeOid		- oid of the type of this expression
 * 	opType		- type of this expression
 *	oper		- the Oper node if it is an OPER_EXPR or the
 *			  Func node if it is a FUNC_EXPR
 *	args		- arguments to this expression
 * ----------------
 */
typedef enum op_type_t {
    OP_EXPR, FUNC_EXPR, OR_EXPR, AND_EXPR, NOT_EXPR
} op_type_t;

typedef struct expr_t {
    node_tag_t		type;
    oid_t			type_oid;	/* oid of the type of this expr */
    op_type_t		op_type;		/* type of the op */
    node_t		*oper;		/* could be Oper or Func */
    list_t		*args;  	/* list of argument nodes */
} expr_t;
#endif // PRIM_NODES_H
